#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main() {
    int n = 0, m = 0, arr1[10][10] = { 0 }, arr2[10][10] = { 0 }, flag = 0;
    scanf("%d %d", &n, &m);
    int i = 0, j = 0;
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            scanf("%d", &arr1[i][j]);
        }
    }
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            scanf("%d", &arr2[i][j]);
            if (arr1[i][j] != arr2[i][j])
            {
                flag = 1;
            }
        }
    }
    if (flag == 1)
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}